package com.xfd.learn.utils;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * 日志打印统一工具类
 * @since 2024-10-23
 * @author xfd
 */
public abstract class LogPrintUtil {

    private static final Logger logger = LoggerFactory.getLogger(LogPrintUtil.class);

    public static void info(String msg, Object... objects) {
        if (logger.isInfoEnabled()) {
            logger.info(msg, objects);
        }
    }

    public static void warn(String msg, Object... objects) {
        if (logger.isWarnEnabled()) {
            logger.warn(msg, objects);
        }
    }

    public static void debug(String msg, Object... objects) {
        if (logger.isDebugEnabled()) {
            logger.debug(msg, objects);
        }
    }

    public static void error(String msg, Object... objects) {
        if (logger.isErrorEnabled()) {
            logger.error(msg, objects);
        }
    }

    public static void errorWithException(String msg, Throwable throwable, Object... objects) {
        if (logger.isErrorEnabled()) {
            logger.error(msg, throwable, objects);
        }
    }

}
